from flask import Flask, render_template, redirect, url_for

app = Flask(__name__)

"""
通过添加endpoint参数设置别名，默认为函数名，通过url_for('别名')得到路由url
"""


@app.route('/index1', methods=['GET', 'POST'], endpoint='n1')  # http://127.0.0.1:5000/index1
def index():
    v1 = url_for('n1')
    v2 = url_for('n2')
    v3 = url_for('logout')
    print(v1, v2, v3)  # /index /login /logout
    return "Index"


@app.route('/login1', methods=['GET', 'POST'], endpoint='n2')
def login():
    return "login"


@app.route('/logout1', methods=['GET', 'POST'])
def logout():
    return "logout"


if __name__ == '__main__':
    app.run()
